#!/bin/bash
source ../common/common.sh

echo "===INIT==THINKPAD-T440P==="
sudo echo "SUDO ROOT"

echo "=========================="
echo " http://blog.csdn.net/quqi99/article/details/25320181"
echo " http://blog.sina.com.cn/s/blog_568f35c70101rh1d.html"
echo "=========================="

show t "反安装nvidia开源驱动bumblebee libvdpau-va-gl12"
sudo apt-get purge -y bumblebee*
sudo apt-get purge -y libvdpau-va-gl12  

show t "安装nvidia官方驱动"
install_apt_pack "force|nvidia-331 nvidia-settings nvidia-prime"

cd ~/
chk_mkdir temp
cd temp

if [ ! -f /lib/firmware/rtlwifi/rtl8192eefw.bin ]; then
  wget http://www.lwfinger.com/realtek_drivers/rtl8192eefw.bin
  sudo cp -f rtl8192eefw.bin /lib/firmware/rtlwifi
fi

read -p "install Linux Kernel 3.13.9(1) or 3.14.1(2) or 3.16.7(3) or 3.17.6(4) or 3.18.1(5) or None(n)? (1/2/3/4/5/n): " mode

if [ "$mode" == "1" ]; then
  show t "下载Kernel 3.13.9安装包"
  wget http://www.lwfinger.com/realtek_drivers/linux-image-3.13.9_1.1_amd64.deb
  wget http://www.lwfinger.com/realtek_drivers/linux-headers-3.13.9_1.1_amd64.deb

  show t "安装Kernel 3.13.9"
  sudo dpkg -i linux-image-3.13.9_1.1_amd64.deb
  sudo dpkg -i linux-headers-3.13.9_1.1_amd64.deb
elif [ "$mode" == "2" ]; then
  show t "下载Kernel 3.14.1安装包"
  wget kernel.ubuntu.com/~kernel-ppa/mainline/v3.14.1-trusty/linux-headers-3.14.1-031401_3.14.1-031401.201404141220_all.deb
  wget kernel.ubuntu.com/~kernel-ppa/mainline/v3.14.1-trusty/linux-headers-3.14.1-031401-generic_3.14.1-031401.201404141220_amd64.deb
  wget kernel.ubuntu.com/~kernel-ppa/mainline/v3.14.1-trusty/linux-image-3.14.1-031401-generic_3.14.1-031401.201404141220_amd64.deb

  show t "安装Kernel 3.14.1"
  sudo dpkg -i linux-image-3.14.1*.deb linux-headers-3.14.1*.deb

  #show t "卸载内核命令"
  #sudo apt-get remove linux-image-3.14.1* linux-headers-3.14.1*

elif [ "$mode" == "3" ]; then
  show t "下载Kernel 3.16.7安装包"
  wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.7-utopic/linux-headers-3.16.7-031607_3.16.7-031607.201410301735_all.deb
  wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.7-utopic/linux-headers-3.16.7-031607-generic_3.16.7-031607.201410301735_amd64.deb
  wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.7-utopic/linux-image-3.16.7-031607-generic_3.16.7-031607.201410301735_amd64.deb

  show t "安装Kernel 3.16.7"
  sudo dpkg -i linux-image-3.16.7*.deb linux-headers-3.16.7*.deb

elif [ "$mode" == "4" ]; then
  show t "下载Kernel 3.17.6安装包"
  wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.6-vivid/linux-headers-3.17.6-031706_3.17.6-031706.201412071535_all.deb
  wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.6-vivid/linux-headers-3.17.6-031706-generic_3.17.6-031706.201412071535_amd64.deb
  wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.6-vivid/linux-image-3.17.6-031706-generic_3.17.6-031706.201412071535_amd64.deb

  show t "安装Kernel 3.17.6"
  sudo dpkg -i linux-image-3.17.6*.deb linux-headers-3.17.6*.deb

elif [ "$mode" == "5" ]; then
  show t "下载Kernel 3.18.1安装包"
  wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.1-vivid/linux-headers-3.18.1-031801_3.18.1-031801.201412170637_all.deb
  wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.1-vivid/linux-headers-3.18.1-031801-generic_3.18.1-031801.201412170637_amd64.deb
  wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.1-vivid/linux-image-3.18.1-031801-generic_3.18.1-031801.201412170637_amd64.deb

  show t "安装Kernel 3.18.1"
  sudo dpkg -i linux-image-3.18.1*.deb linux-headers-3.18.1*.deb

fi
